﻿using ReactiveUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Disposables;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ScienceAIApp.Views.SubViews;
/// <summary>
/// Interaction logic for ImageRecordView.xaml
/// </summary>
public partial class ImageRecordView
{
    public ImageRecordView()
    {
        InitializeComponent();
        this.WhenActivated(_activated);
    }

    private void _activated(CompositeDisposable disposable)
    {
        this.OneWayBind(
            ViewModel,
            vm=>vm.CurrentRecord,
            v=>v.Visibility,
            CurrentRecord => CurrentRecord == null ? Visibility.Hidden : Visibility.Visible
            ).DisposeWith(disposable);

        // 序列名称绑定
        this.OneWayBind(
                ViewModel,
                vm => vm.ShowDescription,
                v => v.ShowDescription.Text)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.Dimension,
                v => v.DimensionBlock.Text)
            .DisposeWith(disposable);

        this.OneWayBind(
                ViewModel,
                vm => vm.CreateTime,
                v => v.CreateBlock.Text)
            .DisposeWith(disposable);

        // 选中状态
        this.OneWayBind(
                ViewModel,
                vm => vm.IsChecked,
                v => v.ChooseImg.Visibility,
                isCheck => isCheck ? Visibility.Visible : Visibility.Collapsed)
            .DisposeWith(disposable);

        // 选中状态
        this.OneWayBind(
                ViewModel,
                vm => vm.IsChecked,
                v => v.PatientSeriesBorder.BorderThickness,
                isCheck => isCheck ? new Thickness(2) : new Thickness(0))
            .DisposeWith(disposable);

        this.BindCommand(
                ViewModel,
                vm => vm.ChooseRecordCommand,
                v => v.PatientSeriesBorder,
                nameof(PatientSeriesBorder.MouseDown))
            .DisposeWith(disposable);

        // 删除逻辑
        this.BindCommand(
                ViewModel,
                vm => vm.DeleteRecordCommand,
                v => v.DeleteBorder,
                nameof(PatientSeriesBorder.MouseDown))
            .DisposeWith(disposable);
    }
}
